package com.caval.service;

import com.caval.bean.Comment;
import com.caval.bean.Game;
import com.caval.dao.GameMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class GameServiceImpl implements GameService{
    @Autowired
    private GameMapper gameMapper;

    public void setGameMapper(GameMapper gameMapper) {
        this.gameMapper = gameMapper;
    }

    @Override
    public List<Game> getGameList() {
        return gameMapper.getGameList();
    }

    @Override
    public Game getDetail(int game_id) {
        return gameMapper.getDetail(game_id);
    }

    @Override
    public List<Comment> getCommentList(int game_id) {
        return gameMapper.getCommentList(game_id);
    }

    @Override
    public int addComment(int user_id, int game_id, String comment, double score) {
        Map<String,Object> map = new HashMap<>();
        map.put("user_id",user_id);
        map.put("game_id",game_id);
        map.put("comment",comment);
        map.put("score",score);
        return gameMapper.addComment(map);
    }

    @Override
    public void delComment(Map<String,Object> map) {
        gameMapper.delComment(map);
    }
}
